#pragma once
#include "Protocol.hpp"

namespace kzz
{
    class Cal
    {
    public:
        Cal() {}
        kzz::ReSponse Execute(kzz::Request &req)
        {
            ReSponse res(0, 0);
            switch (req.Oper())
            {
            case '+':
                res.SetResult(req.X() + req.Y());
                break;
            case '-':
                res.SetResult(req.X() - req.Y());
                break;
            case '*':
                res.SetResult(req.X() * req.Y());
                break;
            case '/':
                if (req.Y() == 0)
                {
                    res.SetCode(1);
                    res.SetResult(0);
                    break;
                }
                res.SetResult(req.X() / req.Y());
                break;
            case '%':
                if (req.Y() == 0)
                {
                    res.SetCode(2);
                    res.SetResult(0);
                    break;
                }
                res.SetResult(req.X() % req.Y());
                break;
            default:
                res.SetCode(3);
                res.SetResult(0);
                std::cout << "unvaild code" << std::endl;
            }

            return res;
        }

    private:
    };
}